package io;

import java.io.*;

/**
 * 利用缓冲字符输入流将src/main/java目录下的所有  .java文件内容输出到控制条
 */
public class Test07 {
    public static void main(String[] args) throws IOException {
        File dirs = new File("./src/main/java");

        File [] dir = dirs.listFiles();
        System.out.println(dir.length);
        int i = 0;
        for (File file : dir) {
            File []subs = file.listFiles(f->f.getName().endsWith(".java"));
            for (File sub : subs ){
                i++;
                System.out.println("第"+i+"次输出");
                FileInputStream fis = new FileInputStream(sub);
                InputStreamReader isr = new InputStreamReader(fis);
                BufferedReader br = new BufferedReader(isr);
                String line;
                while ((line = br.readLine())!=null){
                    System.out.println(line);
                }
                br.close();
            }
        }

    }
}
